﻿////////////////////////////////////////////////////////////////////////////
// 
// Copyright (C) 2007 e-Channels CORPORATION
// 
// ALL RIGHTS RESERVED BY e-Channels CORPORATION, THIS PROGRAM
// MUST BE USED SOLELY FOR THE PURPOSE FOR WHICH IT WAS  
// FURNISHED BY e-Channels CORPORATION, NO PART OF THIS PROGRAM
// MAY BE REPRODUCED OR DISCLOSED TO OTHERS, IN ANY FORM
// WITHOUT THE PRIOR WRITTEN PERMISSION OF e-Channels CORPORATION.
// USE OF COPYRIGHT NOTICE DOES NOT EVIDENCE PUBLICATION
// OF THE PROGRAM
// 
//			e-Channels CONFIDENTIAL AND PROPRIETARY
// 
////////////////////////////////////////////////////////////////////////////
// 
// $Log: ResourceCenter.java,v $
// Revision 1.2  2010/10/29 09:29:26  base_dev_guoxiaofeng
// �޸�����
//
// Revision 1.1  2009/07/04 06:51:37  base_dev_fuwei
// ��ʼ�汾
//
// Revision 1.2  2009/03/16 10:26:43  zhuding
// ͳһ�޸��ļ�����ΪUTF-8
//
// Revision 1.1  2008/05/05 12:28:27  zhanghao
// 初始版本
//
// Revision 1.3  2008/04/15 06:45:49  zhanghao
// 版本合并
//
// Revision 1.2  2007/08/16 07:41:14  zhanghao
// 重构
//
// Revision 1.1  2007/07/23 07:50:23  zhanghao
// For EMP 重构版本
//
// Revision 1.2  2006/12/11 02:54:14  zhanghao
// 添加重复资源和语种的异常处理
//
// Revision 1.1  2006/12/04 03:55:47  zhanghao
// 用于页面多语言显示的资源处理类
//
//
package cn.com.zzz.tag;

import java.util.Map;

import cn.bbs.ba.exception.BAException;


/**
 * Liana 语言资源控制中心<br/> 示例：<br/> String file = "...";<br/> ResourceCenter test = new ResourceCenter( file );<br/>
 * System.out.println( test.getResouceDisplayAt( "欢迎", "en_US" ) );<br/>
 * 
 * @version 1.1 2007-07-23
 * @author zhanghao@yuchengtech.com
 */
public class ResourceCenter {
	/**
	 * 存储资源的HashMap
	 */
	private Map itsResourceHashMap;

	/**
	 * 禁用默认构造函数
	 */
	private ResourceCenter() {
		// 禁用默认构造函数
	}

	/**
	 * Constructor for ResourceCenter.
	 * 
	 * @param resourceFilePathName
	 *            String
	 * @throws TranFailException
	 */
	public ResourceCenter(String resourceFilePathName) throws BAException {
		this();
		ResourceXMLReader reader = new ResourceXMLReader( resourceFilePathName );
		itsResourceHashMap = reader.getResoures();
	}

	/**
	 * Method getResouceDisplayAt.
	 * 
	 * @param resourceName
	 *            String
	 * @param language
	 *            String
	 * @return String
	 */
	public String getResouceDisplayAt( String resourceName, String language )
	{
		Resource resource = (Resource) itsResourceHashMap.get( resourceName );
		if ( resource == null )
		{
			return resourceName;
		}
		return resource.getValueAt( language );
	}
	
	public Map getResourceHashMap() {
		return itsResourceHashMap;
	}
}
